﻿using FingerTip.Domain.Apps.Commands;
using FingerTip.Domain.Apps.Events;
using FingerTip.Framework.Domain;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;

namespace FingerTip.Domain.Apps
{
    public class App:AggregateRoot
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public string Folder { get; set; }
        public AppStatus Status { get; set; }

        public App() { }

        private App(CreateApp command) : base(command.Id)
        {
            Name = command.Name;
            Description = command.Description;
            Folder = command.Folder;
            Status = AppStatus.Active;
            AddEvent(new AppCreated
            {
                AggregateRootId = Id,
                Name = Name,
                Description = Description,
                Folder = Folder,
                Status = Status
            });
        }

        public static App CreateNew(CreateApp command,IValidator<CreateApp> validator)
        {
            validator.ValidateCommand(command);
            return new App(command);
        }
    }
}
